package dk.itu.spct;

import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;

import org.mt4j.AbstractMTApplication;
import org.mt4j.components.visibleComponents.widgets.MTImage;
import org.mt4j.input.inputProcessors.globalProcessors.CursorTracer;
import org.mt4j.sceneManagement.AbstractScene;
import org.mt4j.util.MTColor;

import processing.core.PImage;

public class UserInterface extends AbstractScene {
	
	AbstractMTApplication mtApplication;

	public UserInterface(AbstractMTApplication mtApplication, String name) {
		super(mtApplication, name);
		this.mtApplication = mtApplication;
		this.setClearColor(new MTColor(146, 150, 188, 255));
		this.registerGlobalInputProcessor(new CursorTracer(mtApplication, this));
	}
	
	public void loadImage(BufferedImage img) {
        AffineTransform transform = new AffineTransform();
		BufferedImage transformed = new BufferedImage(img.getWidth(), img.getHeight(), BufferedImage.TRANSLUCENT);
		Graphics2D gR = transformed.createGraphics();
		gR.drawRenderedImage(img, transform);
		gR.dispose();

		PImage tempImage = new PImage(transformed);

		this.getCanvas().addChild(new MTImage(mtApplication, tempImage));
	}
	
	@Override
	public void init() {
	}
 
	@Override
	public void shutDown() {
	}
}
